package testcase.validationtest;

import junit.framework.TestCase;
import validation.*;
import card.Card;
import card.Cardset;

public class TrioWithSoloChainTest extends TestCase{
	private Type trioWithSoloChain;
	private Cardset cardset;
	
	@Override
	public void setUp(){
		trioWithSoloChain = TrioWithSoloChain.getInstance();
	}
	@Override
	public void tearDown(){
		trioWithSoloChain.clear();
		trioWithSoloChain=null;
	}
	// testcases
	public void testIdentifyMinCards(){
		cardset = new Cardset(8);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('d','6'));
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, trioWithSoloChain);
	}
	
	public void testIdentifyMaxCards(){
		cardset = new Cardset(20);
		cardset.clear();
		cardset.add(new Card('d','3'));
		cardset.add(new Card('h','4'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('s','6'));
		cardset.add(new Card('c','7'));
		cardset.add(new Card('h','X'));
		cardset.add(new Card('c','X'));
		cardset.add(new Card('h','X'));
		cardset.add(new Card('d','J'));
		cardset.add(new Card('s','J'));
		cardset.add(new Card('c','J'));
		cardset.add(new Card('h','Q'));
		cardset.add(new Card('d','Q'));
		cardset.add(new Card('s','Q'));
		cardset.add(new Card('c','K'));
		cardset.add(new Card('h','K'));
		cardset.add(new Card('d','K'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('d','A'));
		cardset.add(new Card('h','A'));
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, trioWithSoloChain);
	}
	
	public void testIdentifyCardChainWith2(){
		cardset = new Cardset(8);
		cardset.clear();
		cardset.add(new Card('s','Q'));
		cardset.add(new Card('c','K'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('c','A'));
		cardset.add(new Card('s','A'));
		cardset.add(new Card('h','2'));
		cardset.add(new Card('c','2'));
		cardset.add(new Card('s','2'));		
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testIdentifyInsufficientCards(){
		cardset = new Cardset(7);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('c','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('d','J'));
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, null);
	}

	public void testIdentifyCardChainWithSamePair(){
		cardset = new Cardset(16);
		cardset.clear();
		cardset.add(new Card('s','J'));
		cardset.add(new Card('c','J'));
		cardset.add(new Card('h','J'));
		cardset.add(new Card('d','Q'));
		cardset.add(new Card('s','Q'));
		cardset.add(new Card('c','Q'));
		cardset.add(new Card('d','X'));
		cardset.add(new Card('s','X'));
		cardset.add(new Card('c','X'));
		cardset.add(new Card('d','9'));
		cardset.add(new Card('s','9'));
		cardset.add(new Card('c','9'));
		cardset.add(new Card('h','K'));
		cardset.add(new Card('d','K'));
		cardset.add(new Card('c','K'));
		cardset.add(new Card('s','K'));
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, trioWithSoloChain);
	}
	
	public void testIdentifyCardChainAcrossBoundary(){
		cardset = new Cardset(12);
		cardset.clear();
		cardset.add(new Card('s','A'));
		cardset.add(new Card('c','A'));
		cardset.add(new Card('h','A'));
		cardset.add(new Card('d','2'));
		cardset.add(new Card('s','2'));
		cardset.add(new Card('c','2'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('d','J'));
		cardset.add(new Card('c','Q'));
		cardset.add(new Card('c','K'));		
		Type result = trioWithSoloChain.identify(cardset);
		assertEquals(result, null);
	}
	
	public void testPriorty_1(){
		cardset = new Cardset(8);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','6'));		
		cardset.add(new Card('d','7'));

		Cardset temp = new Cardset(8);
		temp.add(new Card('s','8'));
		temp.add(new Card('d','8'));
		temp.add(new Card('h','8'));
		temp.add(new Card('d','9'));
		temp.add(new Card('s','9'));
		temp.add(new Card('s','9'));
		temp.add(new Card('s','X'));
		temp.add(new Card('d','J'));
		trioWithSoloChain.lessPriorityThan(cardset);
		boolean result = trioWithSoloChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_2(){
		cardset = new Cardset(12);
		cardset.clear();
		cardset.add(new Card('s','3'));
		cardset.add(new Card('c','3'));
		cardset.add(new Card('h','3'));
		cardset.add(new Card('d','4'));
		cardset.add(new Card('s','4'));
		cardset.add(new Card('h','4'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('h','5'));
		cardset.add(new Card('s','5'));
		cardset.add(new Card('s','6'));
		cardset.add(new Card('d','7'));	
		cardset.add(new Card('d','8'));	
		Cardset temp = new Cardset(12);
		temp.add(new Card('s','Q'));
		temp.add(new Card('s','X'));
		temp.add(new Card('d','8'));
		temp.add(new Card('h','K'));
		temp.add(new Card('d','K'));
		temp.add(new Card('s','K'));
		temp.add(new Card('d','A'));
		temp.add(new Card('s','A'));
		temp.add(new Card('c','A'));
		temp.add(new Card('h','2'));
		temp.add(new Card('s','2'));
		temp.add(new Card('c','2'));


		trioWithSoloChain.lessPriorityThan(cardset);
		boolean result = trioWithSoloChain.lessPriorityThan(temp);
		assertEquals(result, true);
	}
	
	public void testPriorty_3(){
		cardset = new Cardset(8);
		cardset.clear();
		cardset.add(new Card('h','5'));
		cardset.add(new Card('d','5'));
		cardset.add(new Card('s','5'));
		cardset.add(new Card('h','6'));
		cardset.add(new Card('d','6'));
		cardset.add(new Card('c','6'));
		cardset.add(new Card('s','7'));
		cardset.add(new Card('d','8'));

		Cardset temp = new Cardset(8);
		temp.add(new Card('s','5'));
		temp.add(new Card('c','5'));
		temp.add(new Card('d','5'));
		temp.add(new Card('c','6'));
		temp.add(new Card('s','6'));
		temp.add(new Card('d','6'));
		temp.add(new Card('s','8'));
		temp.add(new Card('d','7'));		
		trioWithSoloChain.lessPriorityThan(cardset);
		boolean result = trioWithSoloChain.lessPriorityThan(temp);
		assertEquals(result, false);
	}
	
}
